Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: simplify encoder's LRU #65

Merged
merged 1 commit into from
Dec 25, 2023
Merged

Conversation

muktihari
Copy link
Owner

@muktihari muktihari commented Dec 25, 2023

LRU implementation is extracted from inside Encoder to a new lru struct and it is now simplified for easier maintainability. It easier to read, test and benchmark. The sec/op is pretty much similar but the B/op and allocs/op is slightly reduced.

benchstat:

goos: darwin
goarch: amd64
pkg: github.com/muktihari/fit/encoder
cpu: Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
                                        old.txt                  new.txt               
                                         sec/op       sec/op     vs base               
Encode/normal_header_zero-4            80.07m ±  7%   79.36m ± 4%       ~ (p=0.063 n=10)
Encode/normal_header_15-4              81.42m ± 73%   80.19m ± 8%       ~ (p=0.247 n=10)
Encode/compressed_timestamp_header-4   72.55m ± 30%   72.38m ± 0%       ~ (p=0.123 n=10)
geomean                                77.91m         77.23m       -0.88%

                                        old.txt                   new.txt               
                                          B/op          B/op      vs base               
Encode/normal_header_zero-4            3.304Mi ± 0%   3.133Mi ± 0%  -5.18% (p=0.000 n=10)
Encode/normal_header_15-4              3.054Mi ± 0%   3.053Mi ± 0%       ~ (p=0.053 n=10)
Encode/compressed_timestamp_header-4   2.517Mi ± 0%   2.342Mi ± 0%  -6.96% (p=0.000 n=10)
geomean                                2.939Mi        2.819Mi       -4.10%

                                        old.txt                 new.txt               
                                       allocs/op    allocs/op   vs base               
Encode/normal_header_zero-4            108.5k ± 0%   103.5k ± 0%  -4.59% (p=0.000 n=10)
Encode/normal_header_15-4              101.0k ± 0%   101.0k ± 0%  -0.02% (p=0.000 n=10)
Encode/compressed_timestamp_header-4   108.5k ± 0%   103.5k ± 0%  -4.59% (p=0.000 n=10)
geomean                                105.9k        102.7k       -3.09%

@muktihari muktihari added enhancement New feature or request performance Changes related to performance improvement labels Dec 25, 2023
@muktihari muktihari self-assigned this Dec 25, 2023
@muktihari muktihari changed the title perf: simplify encoder's lru perf: simplify encoder's LRU Dec 25, 2023
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ec124c4) 100.00% compared to head (b5aa4e3) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #65   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           25        26    +1     
  Lines         3007      2986   -21     
=========================================
- Hits          3007      2986   -21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@muktihari muktihari merged commit 9774837 into master Dec 25, 2023
1 check passed
@muktihari muktihari deleted the perf/simplify-encoder-lru branch December 25, 2023 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance Changes related to performance improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants